<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <title>BiwaScheme</title>
    <link href="/website/css/screen.css" rel="stylesheet" type="text/css">
    <link href="/website/css/jquery.terminal-2.3.0.css" rel="stylesheet" type="text/css"></script>
    <link href="/website/css/prism-coy.css" rel="stylesheet" type="text/css"></script>
    <script src="/release/biwascheme-@VERSION@-min.js" type="text/javascript"></script>
    <script src="/website/js/jquery.mousewheel.min.js" type="text/javascript"></script>
    <script src="/website/js/jquery.timers.min.js" type="text/javascript"></script>
    <script src="/website/js/jquery.cookie.min.js" type="text/javascript"></script>
    <script src="/website/js/jquery.terminal-2.3.0.js" type="text/javascript"></script>
    <script src="/website/js/prism.js" type="text/javascript"></script>
    <script src="/website/js/prism-scheme.js" type="text/javascript"></script>
    <script src="/website/js/jquery.terminal.prism.js" type="text/javascript"></script>
    <script src="/website/js/keyboard.js" type="text/javascript"></script>
    <script src="/website/js/biwascheme_terminal.js" type="text/javascript"></script>
  </head>
  <body>
    <a href="https://github.com/biwascheme/biwascheme"><img style="position: absolute; top: 0; right: 0; border: 0;" src="https://s3.amazonaws.com/github/ribbons/forkme_right_darkblue_121621.png" alt="Fork me on GitHub"></a>

    <div id="menu">
      <a href="/index.html">
        <img src="/website/images/biwascheme_logo.png" alt="logo"
             title="BiwaScheme logo by @jcubic">
      </a>
      <ul>
        <li><a href='/doc/features.html'>Features</a></li>
        <li><a href='/doc/getting_started.html'>Getting Started</a></li>
        <li><a href='/doc/reference.html'>Reference</a></li>
        <li><a href='/doc/faq.html'>FAQ</a></li>
        <li><a href='/doc/index.html'>Other docs</a></li>
      </ul>
    </div>
    <div id="content">
<h2 id="biwascheme-javascript-api">BiwaScheme JavaScript API</h2>
<p>Moved to <a href="http://www.biwascheme.org/doc/reference.html#js-api">reference.md</a></p>
<h3 id="type-conversion">Type conversion</h3>
<ul>
<li>Scheme number == JavaScript number</li>
<li>Scheme string == JavaScript string</li>
<li><p>Scheme vector == JavaScript array</p>
</li>
<li><p>Scheme nil = <code>BiwaScheme.nil</code></p>
</li>
<li><p>Scheme pair = <code>BiwaScheme.Pair</code></p>
<ul>
<li>make a pair in js : <code>new BiwaScheme.Pair(1, 2)</code></li>
<li>check x is a pair : <code>BiwaScheme.isPair(x)</code>  (returns <code>false</code> for nil)</li>
<li>check x is a proper list : <code>BiwaScheme.isList(x)</code>  (returns <code>true</code> for nil)</li>
<li>pair -&gt; js array : <code>list.to_array()</code></li>
<li>js array -&gt; list (shallow): <code>BiwaScheme.array_to_list(1, 2, [3])</code> =&gt; <code>(list 1 2 (vector 3 4))</code></li>
<li>js array -&gt; list (deep): <code>BiwaScheme.deep_array_to_list(1, 2, [3])</code> =&gt; <code>(list 1 2 (list 3 4))</code></li>
<li>alist -&gt; js obj : <code>BiwaScheme.alist_to_js_obj(alist)</code><ul>
<li>eg. <code>&#39;((a 1) (b 2))</code> is converted to <code>{a: 1, b: 2}</code></li>
</ul>
</li>
<li>js obj -&gt; alist : <code>BiwaScheme.js_obj_to_alist({a: 1, b: 2})</code></li>
</ul>
</li>
<li><p>Scheme symbol = <code>BiwaScheme.Symbol</code></p>
<ul>
<li>js string -&gt; symbol : <code>Sym(&quot;asdf&quot;)</code></li>
<li>symbol -&gt; js string : <code>sym.name</code></li>
</ul>
</li>
<li><p>Scheme function = an array, with <code>ary.closure_p</code> is set to <code>true</code></p>
<ul>
<li><code>BiwaScheme.isClosure(x)</code> returns <code>true</code> when <code>x</code> is a Scheme function</li>
</ul>
</li>
</ul>
    </div>

    <!-- Google Analytics -->
    <script>
      (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
      (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
      m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
      })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

      ga('create', 'UA-2023947-5', 'auto');
      ga('send', 'pageview');
    </script>
  </body>
</html>
